-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modular arithmetic based on Data.Nat.Bounded
#2257
#2292
base: master
Are you sure you want to change the base?
Conversation
…unded.Properties`
I, personally, don't like implementing modular arithmetic this way, for two actual reasons and one emotional reason:
|
@Taneb thanks for the frank feedback, and I do get both the rational and emotional sides of it. Re: definition via quotient rings, so that you can get polynomial ideals, absolutely, absolutely, absolutely. But until that development comes home, the lack of modular arithmetic has been a years-long embarrassing gap in the library. But I'd be entirely happy to be patient rather than agitate to have this merged, and indeed to convert to Re: efficiency. @JacquesCarette has already made the point that it would be good to have one model for 'easy' verification, with others for 'efficient' implementation... but again, absent the latter... Re: emotion. Contrary perhaps to appearances, I've no (over-)commitment to where things live, so if you feel I'm squatting on an important part of the namespace/concrete hierarchy under |
Re: inefficiency (@Taneb 's comment above)
|
And then there's the implementation based on symmetric difference and quotients. It's currently written in very Conor-ish lingo, but could stdlib-ified. |
This is still DRAFT, but suggest at some point we discuss, and agree, these various competing suggestions for an efficient design. I'd be happy to close this PR in favour of something better, but for the contribution of an efficient approach to the quotient relation/reasoning, so hopefully that can reused elsewhere. |
Adds:
Data.Integer.Modulo.{Base|Literals|Properties}
;Data.Nat.Bounded.Base
andData.Nat.Bounded.Properties
; noCHANGELOG
for these revisions, given the recency of the (hypothetical/proposed) additions of those modules;IsRing
structure/Ring
bundle based on integers moduloOutstanding issues (could be tackled mostly/all by downstream PRs):
Data.Nat.Bounded
#2257 ; merge conflict inCHANGELOG
(now fixed);Commutative
properties of addition and multiplication;DecSetoid
structure;fromℤ
gives rise to aRingHomomorphism
(or that there's aSemiringHomomorphism
based on the quotient mapfromℕ
...);README.Data.Integer.Modulo
etc.;mod n
isn't developed in terms ofRelation.Binary.Reasoning.Syntax
;ℕ
, so no attempt to consider efficient 'wide'Word64
-(or better)-sized modulus cf. Modular arithmetic #581But all of this should be consider provisional until we've achieved consensus on the what, where, and how, of tackling #581 (see @Taneb 's comment below).